//
//  YSGPersonInfoCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/11/18.
//  Copyright © 2020 QDSG. All rights reserved.
//

import UIKit

class YSGPersonInfoCell: UITableViewCell {
    
    func configure(with vm: YSGPersonInfoCellViewModel) {
        titleLabel.text = vm.cellType.title
        avatarView.isHidden = vm.cellType != .avatar
        nameLabel.isHidden = vm.cellType != .name
        
        let placeholder = UserDefaults.usersex == "男" ? UIImage(named: "avatar_male") : UIImage(named: "avatar_female")
        avatarView.kf.setImage(with: URL(string: vm.avatar), placeholder: placeholder)
        nameLabel.text = vm.name
    }
    
    @IBOutlet private weak var titleLabel: UILabel!
    @IBOutlet private weak var nameLabel: UILabel!
    @IBOutlet weak var avatarView: UIImageView! {
        didSet {
            avatarView.contentMode = .scaleAspectFill
            avatarView.layer.cornerRadius = avatarView.height / 2
            avatarView.clipsToBounds = true
        }
    }
}
